#!/usr/bin/env python3

import sys
import datetime
import os
import subprocess
import re  # 正则
import os.path
from pathlib import Path

# sud_all_ver=sys.argv[1]
# src_localization_repo_dir=sys.argv[2]
# pakcages_root_dir=sys.argv[3]

# 检查点：
#         localization的分支


print("\n")
print("-----------------start------------------------")
print("run in host pc!!!!!!!!")
print("do all ready work and generate cmdlist run docker")
print("\n\n")

ws_root="/home/nio/repos/localization/sud_release_res"

localization_repo_dir=ws_root+"/localization"
localization_branch="feature/fix_module_switch"
if not Path(localization_repo_dir).is_dir():
  print(localization_repo_dir+" not exist !!!!!!!!")
  os.system('git clone git@git.nevint.com:hongyuan.yuan/localization.git %s'%(localization_repo_dir))
os.system('cd %s && git pull && git checkout %s && ./get_dependencies.sh -a'%(localization_repo_dir,localization_branch))

cosine_perception_repo_dir=ws_root+"/cosine_perception"
if not Path(cosine_perception_repo_dir).is_dir():
  print(cosine_perception_repo_dir+" not exist !!!!!!!!")
  os.system('git clone git@git.nevint.com:aa_sud/cosine_perception.git %s'%(cosine_perception_repo_dir))
os.system('cd %s && git checkout feature/localization && git pull && git fetch --all && git rebase origin/develop_orin_sud'%(cosine_perception_repo_dir))




sud_docker_ver="v1.0.0"
sud_docker_ori="adas-img.nioint.com/aa-sdk/cosine_orin_sud"
run_docker_cmd="sudo docker run --rm -it -v"+" "+ws_root+":"+"/code"+" "+sud_docker_ori+":"+sud_docker_ver
print("\n\n")
print("[cmd_list run in host pc!!!!!!!!!!]")
print(run_docker_cmd)
print("\n\n")

print("[cmd_list run in docker!!!!!!!!]")
print("python3 /code/code_tool_nio/sud_faban/one_key_scripts/2_release.py")